package book.cert;

import java.io.FileInputStream;
import java.io.IOException;
import java.math.BigInteger;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.Signature;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;

public class X509CertificateTest {

	public static void main(String[] args) throws NoSuchAlgorithmException, KeyStoreException, CertificateException, IOException {
		
		FileInputStream in = new FileInputStream("/Users/apple/Documents/demo.keystore");
		KeyStore store = KeyStore.getInstance("jKS");
		store.load(in, "123456".toCharArray());
		in.close();
		
		X509Certificate x509 = (X509Certificate)store.getCertificate("ss");
		System.out.println(new BigInteger(x509.getPublicKey().getEncoded()));
		
		Signature sign = Signature.getInstance(x509.getSigAlgName());
	}
}
